package com.lenovo.smarttraffic.interfaceImpl;

import android.content.Context;
import android.webkit.JavascriptInterface;

import com.lenovo.smarttraffic.api.ITitle;
import com.lenovo.smarttraffic.api.JsToNativeInterFaceSec;
import com.lenovo.smarttraffic.api.JsToNativeInterfaceFir;
import com.lenovo.smarttraffic.util.ToastUtil;

/**
 * Created by Caleb.F
 * on 2020-06-04
 * at 15:31
 */
public class JsToJavaImpl implements JsToNativeInterfaceFir, JsToNativeInterFaceSec {
    private Context mContext;
    private ITitle mITitle;
    private Boolean isFirstClick = false;

    public JsToJavaImpl(Context context, ITitle title) {
        mContext = context;
        mITitle = title;

    }

    @JavascriptInterface
    @Override
    public void setTitle(String title) {
        mITitle.setTitle(title);

    }


    @JavascriptInterface
    @Override
    public void showToast(String content) {
        if (!isFirstClick) {
            ToastUtil.showToastShort(content);
        } else {
            ToastUtil.showToastShort("您已领取");
        }
        isFirstClick = true;
    }


}


